# 空气质量查询工具
# • 键盘接收pm2.5的值
# • 根据右表，计算出今天的空气质量
# • 循环输入，按q退出
# while 1:
#     pm=input('请输入PM2.5的值：')
#     if pm=='q':
#         break
#     elif  51<=int(pm)<=100:
#         print('良')
#     elif  101<=int(pm)<=150:
#         print('轻度污染')
#     elif  151<=int(pm)<=200:
#         print('中度污染')
#     elif  201<=int(pm)<=300:
#         print('重度污染')
#     elif  0<int(pm)<=50:
#         print('优')
#     elif int(pm)>300:
#         print('严重污染')

#  猜大小游戏
# • 预备知识：random模块randint
# • 模拟色子：随机生成3个1~6的数，
# • 三个色子和在3~10 => 小， 11~18=>大
# • 用户在键盘输入猜”大”或”小“
# ，一轮结果，给出结果
# • 可无限玩，直到用户输入exit，结束后，统计用户玩的次数，胜率
# • 扩展：增加金豆，进场默认1000金豆，猜对赢100金豆，猜错输100金豆，金豆低于100不能继续玩
# • 扩展：增加礼品
# import random
# win_time = 0  #赢的次数初始化为零
# lose_time = 0   #输的次数初始化为零
# capial=1000    #金豆初始化为1000
# while capial>=100:
#     a = random.randint(1, 6)
#     b = random.randint(1, 6)
#     c = random.randint(1, 6)    #随机取3个1~6之间的整数
#     sum = a + b + c
#     user=input('Please input big or little or exit:')   #用户输入
#     if user!='big' and user!='little' and user!='exit':  #输入格式不对，给予提示
#         print('Your input format is incorrecet')
#     else:
#         if user=='exit' :
#             print('game over')
#             break      #用户输入为exit，退出程序
#         print('The summary is ',sum)      #显示三个骰子的总数
#         if (3<=sum<=10 and user=='little') or (11<=sum<=18 and user=='big'):  #判定用户输入与骰子总数关系
#             win_time += 1  #赢的次数加一
#             capial+=100    #金豆加一百
#             print('Congratulations!You win!','now you have already won',win_time,"times","and now your capital is",capial,'￥')
#         elif (3<=sum<=10 and user=='big') or (11<=sum<=18 and user=='little'):   #判定用户输入与骰子总数关系
#             lose_time += 1   #输的次数加一
#             capial-=100    #金豆减一百
#             print('Regretful!You lose!','Now you have already lost',lose_time,'times',"and now your capital is",capial,'￥')
#         sum_times=win_time+lose_time   #玩的总次数
#         win_rate = win_time/sum_times * 100   #胜率算式
#         if sum_times>=10 and win_rate>=60:     #奖励机制：游戏次数在10把以上，且胜率高于60%，奖励200￥
#             capial+=200
#             print('Your win rate are over 80%,we will reward you 200￥,and now you have',capial,'￥')
#         print('Now your win rate is %.2f%%'%win_rate)
#         print('You have played it',sum_times,'times')

# for循环实现输出九九乘法表
# for i in range(1, 10):
#     for j in range(1, i+1):
#         print(f'{j}x{i}={i*j}\t', end='')
#     print()

#千分位格式化
# num1=input("please input a nubmer:")
# num2=num1[::-1]
# num3=""
# for i in range(len(num2)):
#     if (i+1)%3==0 and i !=(len(num2)-1):
#         num3+=num2[i]+','
#     else:
#         num3+=num2[i]
# print(num3[::-1])